#include "Circle.h"

Circle::Circle(){

}


Circle::Circle(const Circle &c1){
  
   (*this) = c1;
   
}

Circle::Circle(const int radius,const MyDisplay &another){

   this->radius = radius;
   
   show = new MyDisplay(another);
   
//   show->createWindow( show->getWidth(), show->getHeight(), 0, 0);
//  show->createGC(0);

}

Circle::Circle(const int radius,const int x ,const int y){

   this->radius = radius;
   this->x=x;
   this->y=y;
}





Circle::~Circle(){

}


bool Circle::draw(){
      
    
     int d;
     int x1,y1;
     x1=0;
     y1 = radius;
     
     
     // initialize the decision variable
     //---------------------------------
     
     d = 3 - 2*radius;
     
     //
     //cout<<"About to draw circle of radius"<<radius<<endl;
     while(x1 < y1){
     
     
         show->drawPoint(x1 + x ,y1 + y);
//	 cout<<"1-->"<< x1 + x<<"  "<<y1 + y<<endl;
	 
	  
	 show->drawPoint(y1 + x ,x1 + y);
//	 cout<<"2-->"<<y1 + y<<"  "<<x1 + x<<endl;
	 
	 show->drawPoint(y1 + x,-x1 + y);
//	 cout<<"3-->"<<y1 + y<<"  "<<-x1 + x<<endl;
	 
	 show->drawPoint(x1 + x,-y1 + y);
//	 cout<<"4-->"<<x1 + x<<"  "<<-y1 + y<<endl;
	 
	 show->drawPoint(-x1 + x,-y1 + y);
//	 cout<<"5-->"<<-x1 + x<<"  "<<-y1 + y<<endl;
	 
	 show->drawPoint(-y1 + x,-x1 + y);
//	 cout<<"6-->"<<-y1 + y<<"  "<<-x1 + x<<endl;
	 
	 show->drawPoint(-y1 + x,x1 + y);
//	 cout<<"7-->"<<-y1 + y<<"  "<<x1 + x<<endl;
	 
	 show->drawPoint(-x1 + x,y1 + y);
//	 cout<<"8-->"<<-x1 + x<<"  "<<y1 + y<<endl;
	 
	 
	  if(d<=0){
	   
	      d = d + 4 * x1 + 6;
	  }else{
	  
	      d = d + 4 *(x1-y1) + 10;
	      y1--;
	  }
	  
	  x1++;
	  
	  
    }
    
    
  //cout<<"END OF CIRCLE DRAWING"  <<endl;
  //cout<<"###################################################"<<endl;
  
return true;
}



   bool Circle::draw(int x,int y){
   
       this -> x = x;
       this -> y = y;
       
       draw();
   }
     
   bool Circle::draw(int radius){
      
         this->radius = radius;

       draw();	 	 
   
   }
     
   bool Circle::draw(int radius,int x,int y){
   
       this->radius = radius;
       this->x = x;
       this->y = y; 
        
       draw();
   }
   
   
   
                                             
